<template>
    <el-dialog title="" visible :show-close="false" class="wrap" size="tiny">
    <i class="el-icon-close close" @click="cancel" style="color: white;z-index: 99;"></i>
	    <div class="bt">修改</div>        
	    <el-form label-width="150px" class="form">
            <el-form-item label="课程名称">
                <el-input v-model="form.kcmc" :readonly='true' class="select-block"></el-input>
            </el-form-item>
            <el-form-item label="教材名称">
                <el-input v-model="form.jcmc" :readonly='true' class="select-block"></el-input>
            </el-form-item>
            <el-form-item label="作业内容">
                <el-input v-model="form.nr" type="textarea" :rows="4"   class="select-block"></el-input>
            </el-form-item>
        </el-form>
        <el-button type="primary" class="submit" @click="submit">修改</el-button>
		<el-button type="danger" class="submit" @click="cancel">退出</el-button>
    </el-dialog>
</template>

<script type="text/javascript">
	import qs from 'qs'
    export default {
        props: ['params'],
        data () {
            return {
                form: {
                     kcmc:'',
					 jcmc:'',
					 nr:'',
					 id:'',
                },
                comboxlist:[],
            }
        },
        created () {
        	this.form.id = this.params.list.row.id;
            this.loadinfo();
        },
        methods: {
        	loadinfo(){
 				 var logininfo = JSON.parse(localStorage.logininfo) ;
				         var params3 = qs.stringify({
				           xxid:logininfo.xxid,
				           yhid:logininfo.id,
				           id:this.form.id
						});
 				 this.axios.post(this.$store.state.api+'bjjczymodel/getinfo',params3)
               .then( res =>  {
 							this.form=res.data.data.list[0]
 					 }).catch(res => {
 						 this.$message.warning("服务器异常");
 			 				this.$emit('close', { type: 'info', cancel: true });
 					 })
 			},
                submit () {
                this.$store.state.loading = true;
				var logininfo = JSON.parse(localStorage.logininfo);
                var params2 = qs.stringify({
                	    ids:this.form.id,
                        nr:this.form.nr,
                        xxid:logininfo.xxid,
				        yhid:logininfo.id,
               })
             //执行
                 this.axios.post(this.$store.state.api + 'bjjczymodel/update1',  params2 )
                 .then(res => {
                    if (res.data.code == 1) {
                    	this.$emit('close', {type: 'edit',cancel: false,id:this.params.id});
                    	this.$message.success(res.data.msg);
                        this.$store.state.loading = false;
                    }else{
 						this.$message.warning(res.data.msg);
                    	this.$store.state.loading = false;
                    }
                 }).catch(res => {
 					    this.$message.error("服务器异常");
                	    this.$store.state.loading = false;
				})
            },
            cancel () {
                this.$emit('close',{type:'edit',cancel:true})
            },
        }
    }
</script>

<style lang="less" scoped>
    .wrap {
        text-align: center;
    }
    .form {
        // width: 300px;
        text-align: left;
    }
    .bt{
			position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top:0;
			left:0;
			background: #50BFFF;
			margin-bottom: 20px;
			color:white;
			text-align:left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}
    .select-block {
        display: block;
    }
    .submit {
        width: 120px;
    }
</style>